//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.ysy.tz.core.skin;

import com.sun.javafx.scene.control.behavior.BehaviorBase;
import com.sun.javafx.scene.control.behavior.KeyBinding;
import com.sun.javafx.scene.control.skin.BehaviorSkinBase;
import java.util.ArrayList;
import java.util.List;
import javafx.geometry.NodeOrientation;
import javafx.scene.control.Label;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;

public class CustomerPigNodeSkin extends BehaviorSkinBase<Label, CustomerPigNodeSkin.PigNodeBehavior> {
    protected CustomerPigNodeSkin(Label control) {
        super(control, new PigNodeBehavior(control));
        Label pigNode = (Label)this.getSkinnable();
        pigNode.setStyle("-fx-background-color: #FFFFFF;-fx-border-width:8 8 8 8;-fx-border-style: solid; -fx-border-color:#CEFBEA;-fx-border-insets: 40 0 0 0;");
    }

    public static class PigNodeBehavior extends BehaviorBase<Label> {
        private static final String LEFT = "Left";
        private static final String RIGHT = "Right";
        protected static final List<KeyBinding> PIGNODE_BINDINGS = new ArrayList();

        protected String matchActionForEvent(KeyEvent e) {
            String action = super.matchActionForEvent(e);
            if (action != null) {
                if (e.getCode() == KeyCode.LEFT) {
                    if (((Label)this.getControl()).getEffectiveNodeOrientation() == NodeOrientation.RIGHT_TO_LEFT) {
                        action = "Right";
                    }
                } else if (e.getCode() == KeyCode.RIGHT && ((Label)this.getControl()).getEffectiveNodeOrientation() == NodeOrientation.RIGHT_TO_LEFT) {
                    action = "Left";
                }
            }

            return action;
        }

        protected void callAction(String name) {
            if (!"Left".equals(name) && !"Right".equals(name)) {
                super.callAction(name);
            }

        }

        public void mousePressed(MouseEvent e) {
            super.mousePressed(e);
            Label p = (Label)this.getControl();
            p.requestFocus();
        }

        public PigNodeBehavior(Label pigNode) {
            super(pigNode, PIGNODE_BINDINGS);
        }

        static {
            PIGNODE_BINDINGS.add(new KeyBinding(KeyCode.LEFT, "Left"));
            PIGNODE_BINDINGS.add(new KeyBinding(KeyCode.RIGHT, "Right"));
        }
    }
}
